First Agent
In BindAI, an Agent is the core building block of every AI application. An agent connects a language model with instructions, tools, memory, knowledge, and workflows to perform useful tasks. This guide explains how agents work and how to build your own.What is an Agent?
An agent is responsible for:- Receiving user input
- Building a prompt
- Sending the request to a language model
- Executing tools when required
- Returning the final response
Creating an Agent
The simplest agent only requires a provider, model, and instructions.Agent Components
A BindAI agent is composed of several optional building blocks.
You can start with only a provider and model, then add more capabilities as your application grows.
System Instructions
Instructions define the agent’s personality and behavior.- The agent’s role
- Desired writing style
- Constraints
- Expected output format
Sending Messages
Use thechat() method to send a prompt.
AgentResult.
Structured Output
Agents can also return structured data. Suppose you have a Pydantic model.output argument.
Loading Agents from YAML
Agents can be defined without writing Python code. Example configuration:Streaming Responses
Instead of waiting for the complete answer, responses can be streamed token by token.Agent Lifecycle
Internally, every execution follows the same pipeline.- Receive user input
- Build the prompt
- Load memory
- Retrieve knowledge (if configured)
- Send the request to the language model
- Execute requested tools
- Generate the final response
- Save conversation memory
- Return an
AgentResult
